/**
 * 
 */
package com.appspot.myjsf2;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author andyz
 *
 */
public class GContactsParser {
	public static List<String> getContacts(String rawStr){
		List<String> contacts = new ArrayList<String>();
		Pattern p = Pattern.compile("[aA][dD][dD][rR][eE][sS][sS]='\\S*'\\s");
		Matcher m = p.matcher(rawStr);
		while(m.find()){
//			System.out.println(m.group());
			String rawEntry = m.group().trim();
			int length = rawEntry.length();
			String email = rawEntry.substring(9, length-1);
//			System.out.println(email);
			contacts.add(email);
		}

		return contacts;
	}
}
